<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Plots four different taper desings on a single graph.</title>
<link rel="canonical" href="/Users/mcgrant/Repos/CVX/examples/circuit_design/html/plot_four_tapers.html">
<link rel="stylesheet" href="../../examples.css" type="text/css">
</head>
<body>
<div id="header">
<h1>Plots four different taper desings on a single graph.</h1>
Jump to:&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#source">Source code</a>&nbsp;&nbsp;&nbsp;&nbsp;
Text output
&nbsp;&nbsp;&nbsp;&nbsp;
Plots
&nbsp;&nbsp;&nbsp;&nbsp;<a href="../../index.html">Library index</a>
</div>
<div id="content">
<a id="source"></a>
<pre class="codeinput">
<span class="keyword">function</span> plot_four_tapers(w1,w2,w3,w4)
<span class="comment">% Inputs:</span>
<span class="comment">%      [w1 w2 w3 w4]: an array of taper widths</span>
<span class="comment">%</span>
<span class="comment">% Original code written by Lieven Vandenberghe.</span>
<span class="comment">% Updated by Almir Mutapcic 12/2005</span>

n = size(w1,1);
colormap(gray);
width = zeros(2*n,4);
width([1:2:2*n-1],:) =  [w1 w2 w3 w4];
width([2:2:2*n],:)   =  [w1 w2 w3 w4];
x = zeros(2*n,1);
x([1:2:2*n-1],:) = [0:n-1]';
x([2:2:2*n],:)   = [1:n]';

<span class="comment">% first solution</span>
subplot(411)
hold <span class="string">off</span>
plot([x;flipud(x);0], [0.5*(width(1,1)-width(:,1)); <span class="keyword">...</span>
    flipud(0.5*(width(1,1)+width(:,1))); 0]);
hold <span class="string">on</span>;
fill([x;flipud(x);0]', [0.5*(width(1,1)-width(:,1)); <span class="keyword">...</span>
  flipud(0.5*(width(1,1)+width(:,1))); 0]', 0.9*ones(size([x;x;0]')));
caxis([-1,1]);
plot([x;flipud(x);0], [0.5*(width(1,1)-width(:,1)); <span class="keyword">...</span>
    flipud(0.5*(width(1,1)+width(:,1))); 0]);
ylabel(<span class="string">'width'</span>);

<span class="comment">% second solution</span>
subplot(412)
hold <span class="string">off</span>
plot([x;flipud(x);0], [0.5*(width(1,2)-width(:,2)); <span class="keyword">...</span>
    flipud(0.5*(width(1,2)+width(:,2))); 0]);
hold <span class="string">on</span>;
fill([x;flipud(x);0]', [0.5*(width(1,2)-width(:,2)); <span class="keyword">...</span>
   flipud(0.5*(width(1,2)+width(:,2))); 0]', 0.9*ones(size([x;x;0]')));
caxis([-1,1]);
plot([x;flipud(x);0], [0.5*(width(1,2)-width(:,2)); <span class="keyword">...</span>
    flipud(0.5*(width(1,2)+width(:,2))); 0]);
ylabel(<span class="string">'width'</span>);

<span class="comment">% third solution</span>
subplot(413)
hold <span class="string">off</span>
plot([x;flipud(x);0], [0.5*(width(1,3)-width(:,3)); <span class="keyword">...</span>
    flipud(0.5*(width(1,3)+width(:,3))); 0]);
hold <span class="string">on</span>;
fill([x;flipud(x);0]', [0.5*(width(1,3)-width(:,3)); <span class="keyword">...</span>
  flipud(0.5*(width(1,3)+width(:,3))); 0]', 0.9*ones(size([x;x;0]')));
caxis([-1,1]);
plot([x;flipud(x);0], [0.5*(width(1,3)-width(:,3)); <span class="keyword">...</span>
    flipud(0.5*(width(1,3)+width(:,3))); 0]);
ylabel(<span class="string">'width'</span>);

<span class="comment">% fourth solution</span>
subplot(414)
hold <span class="string">off</span>
plot([x;flipud(x);0], [0.5*(width(1,4)-width(:,4)); <span class="keyword">...</span>
    flipud(0.5*(width(1,4)+width(:,4))); 0]);
hold <span class="string">on</span>;
fill([x;flipud(x);0]', [0.5*(width(1,4)-width(:,4)); <span class="keyword">...</span>
   flipud(0.5*(width(1,4)+width(:,4))); 0]', 0.9*ones(size([x;x;0]')));
caxis([-1,1]);
plot([x;flipud(x);0], [0.5*(width(1,4)-width(:,4)); <span class="keyword">...</span>
    flipud(0.5*(width(1,4)+width(:,4))); 0]);
ylabel(<span class="string">'width'</span>);
xlabel(<span class="string">'segment'</span>);
</pre>
</div>
</body>
</html>